
<style>
/* page */
html,body{
    height: 100%;
    margin: 0;
    padding: 0;
    font-family: "Microsoft YaHei"
}
.el-row{margin-bottom: 20px;}
.g-center{
    display: table-cell;

    vertical-align: middle;
}
.page{
    margin: 20px 0 0;

    text-align: center;
}

.operation{
    margin-bottom: 20px;
}

</style>

<template>
  <router-view id="app" @login="loginDirect" @logout="logoutDirect"></router-view>
</template>

<script>

import instance from './api';
import AllRoutesData from './router/fullpath';
import * as util from './assets/util.js';

// axios Interceptor

let myInterceptor;

export default {
  data() {
    return {
      menuData: null,
      userData: null
    }
  },
  methods: {

    loginDirect: function(newPath){
      
      /*
      * Monitor login events
      * Will trigger the events in views/login.vue
      */

      this.signin(() => {
        this.$router.replace({path:  '/'});
      });
    },
    logoutDirect: function(){
      /*
      * Monitor logout events
      * Will trigger the events in views/index.vue
      */

      //Clear local user information
      util.session('token','');
      //Clear request permission
      instance.interceptors.request.eject(myInterceptor);
      //Clear Authorization
      instance.defaults.headers.common['Authorization'] = '';
      //Back to login page
      this.$router.replace({path: '/login'});
    }
  },
  created: function() {
    /*newPath
    * Start from here!
    */
    
      this.$router.addRoutes(AllRoutesData);
     
  }
}
</script>